namespace DotNetNuke.Services.Log.EventLog
{
    using DotNetNuke.Services.Exceptions;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Text;
    using System.Xml.Serialization;

    [XmlRoot("log", IsNullable=false)]
    public class LogInfo
    {
        private bool _BypassBuffering = false;
        private string _LogConfigID;
        private DateTime _LogCreateDate;
        private long _LogCreateDateNum;
        private string _LogFileID;
        private string _LogGUID = Guid.NewGuid().ToString();
        private int _LogPortalID;
        private string _LogPortalName;
        private DotNetNuke.Services.Log.EventLog.LogProperties _LogProperties;
        private string _LogServerName;
        private string _LogTypeKey;
        private int _LogUserID;
        private string _LogUserName;

        public LogInfo()
        {
            this.LogProperties = new DotNetNuke.Services.Log.EventLog.LogProperties();
            this._LogPortalID = -1;
            this._LogPortalName = "";
            this._LogUserID = -1;
            this._LogUserName = "";
        }

        public void AddProperty(string PropertyName, string PropertyValue)
        {
            try
            {
                if (PropertyName.Length > 50)
                {
                    PropertyName = Strings.Left(PropertyName, 50);
                }
                if (PropertyValue.Length > 500)
                {
                    PropertyValue = "(TRUNCATED TO 500 CHARS): " + Strings.Left(PropertyValue, 500);
                }
                LogDetailInfo objLogDetailInfo = new LogDetailInfo();
                objLogDetailInfo.PropertyName = PropertyName;
                objLogDetailInfo.PropertyValue = PropertyValue;
                this._LogProperties.Add(objLogDetailInfo);
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessPageLoadException(exc);
                
            }
        }

        public static bool IsSystemType(string PropName)
        {
            string refStringHelperL0 = PropName;
            if (((((refStringHelperL0 == "LogGUID") || (refStringHelperL0 == "LogFileID")) || (refStringHelperL0 == "LogTypeKey")) || ((refStringHelperL0 == "LogCreateDate") || (refStringHelperL0 == "LogCreateDateNum"))) || (((refStringHelperL0 == "LogPortalID") || (refStringHelperL0 == "LogPortalName")) || (((refStringHelperL0 == "LogUserID") || (refStringHelperL0 == "LogUserName")) || (refStringHelperL0 == "BypassBuffering"))))
            {
            }
            return (((refStringHelperL0 == "LogServerName") ? 1 : 0) != 0);
        }

        public override string ToString()
        {
            StringBuilder str = new StringBuilder();
            str.Append("<b>LogGUID:</b> " + this.LogGUID + "<br>");
            str.Append("<b>LogType:</b> " + this.LogTypeKey + "<br>");
            str.Append("<b>UserID:</b> " + this.LogUserID.ToString() + "<br>");
            str.Append("<b>Username:</b> " + this.LogUserName + "<br>");
            str.Append("<b>PortalID:</b> " + this.LogPortalID.ToString() + "<br>");
            str.Append("<b>PortalName:</b> " + this.LogPortalName + "<br>");
            str.Append("<b>CreateDate:</b> " + this.LogCreateDate.ToString() + "<br>");
            str.Append("<b>ServerName:</b> " + this.LogServerName + "<br>");
            str.Append(this.LogProperties.ToString());
            return str.ToString();
        }

        [XmlAttribute("BypassBuffering")]
        public bool BypassBuffering
        {
            get
            {
                return this._BypassBuffering;
            }
            set
            {
                this._BypassBuffering = value;
            }
        }

        [XmlAttribute("LogConfigID")]
        public string LogConfigID
        {
            get
            {
                return this._LogConfigID;
            }
            set
            {
                this._LogConfigID = value;
            }
        }

        [XmlAttribute("LogCreateDate")]
        public DateTime LogCreateDate
        {
            get
            {
                return this._LogCreateDate;
            }
            set
            {
                this._LogCreateDate = value;
            }
        }

        [XmlAttribute("LogCreateDateNum")]
        public long LogCreateDateNum
        {
            get
            {
                return this._LogCreateDateNum;
            }
            set
            {
                this._LogCreateDateNum = value;
            }
        }

        [XmlAttribute("LogFileID")]
        public string LogFileID
        {
            get
            {
                return this._LogFileID;
            }
            set
            {
                this._LogFileID = value;
            }
        }

        [XmlAttribute("LogGUID")]
        public string LogGUID
        {
            get
            {
                return this._LogGUID;
            }
            set
            {
                this._LogGUID = value;
            }
        }

        [XmlAttribute("LogPortalID")]
        public int LogPortalID
        {
            get
            {
                return this._LogPortalID;
            }
            set
            {
                this._LogPortalID = value;
            }
        }

        [XmlAttribute("LogPortalName")]
        public string LogPortalName
        {
            get
            {
                return this._LogPortalName;
            }
            set
            {
                this._LogPortalName = value;
            }
        }

        [XmlArray("properties"), XmlArrayItem(ElementName="property", Type=typeof(LogDetailInfo))]
        public DotNetNuke.Services.Log.EventLog.LogProperties LogProperties
        {
            get
            {
                return this._LogProperties;
            }
            set
            {
                this._LogProperties = value;
            }
        }

        [XmlAttribute("LogServerName")]
        public string LogServerName
        {
            get
            {
                return this._LogServerName;
            }
            set
            {
                this._LogServerName = value;
            }
        }

        [XmlAttribute("LogTypeKey")]
        public string LogTypeKey
        {
            get
            {
                return this._LogTypeKey;
            }
            set
            {
                this._LogTypeKey = value;
            }
        }

        [XmlAttribute("LogUserID")]
        public int LogUserID
        {
            get
            {
                return this._LogUserID;
            }
            set
            {
                this._LogUserID = value;
            }
        }

        [XmlAttribute("LogUserName")]
        public string LogUserName
        {
            get
            {
                return this._LogUserName;
            }
            set
            {
                this._LogUserName = value;
            }
        }
    }
}

